package foo;

import java.util.Collection;
import java.util.Iterator;
import java.util.List;

import com.google.common.base.Predicate;

public class GenericPrinter<E extends Printable> {
	E	printer;

	public GenericPrinter(E aPrinter) {
		printer = aPrinter;
	}

	public void printAll(String message) {
		printer.print(message);
	}

	public <T extends Collection<?>> void printCollection(T coll) {
		Iterator<?> iterator = coll.iterator();
		while (iterator.hasNext())
			printAll((String) iterator.next());
	}

	public <T> void printList(List<? extends T> items) {
		for (T item : items) {
			System.err.println(item);
		}
	}

	public void useCondition(Predicate<Printable> condition) {
		if (condition.apply(printer))
			System.out.println("Predicate true");
	}
}
